#include "tile.h"
#include <QPixmap>
#include <QLabel>
#include <QMouseEvent>  

Tile::Tile(int type, int x, int y)
{
    // Initialization code goes her
    QPixmap pixmap;  
    QLabel* label = new QLabel(this); // Create a new QLabel
    switch(type) {
        case 1:
            pixmap.load(":/images/image1.png");
            break;
        case 2:
            pixmap.load(":/images/image2.png");
            break;
        case 3:
            pixmap.load(":/images/image3.png");
            break;
        case 4:
            pixmap.load(":/images/image4.png");
            break;
        default:
            pixmap.load(":/images/default.png");
            break;
    }
    pixmap = pixmap.scaled(50, 50, Qt::KeepAspectRatio, Qt::SmoothTransformation); // Resize the QPixmap to 50x50 pixels
    label->setPixmap(pixmap); // Set the QPixmap to the QLabel
    this->setFixedSize(pixmap.size()); // Set the tile size to the QPixmap size
    this->type = type;
    this->x = x;
    this->y = y;
}

void Tile::mousePressEvent(QMouseEvent* event)
{
    if (event->button() == Qt::LeftButton) {
        emit clicked(this); // Emit the clicked signal when the tile is clicked
    }
}

Tile::~Tile()
{
    // Cleanup code goes here
}
